﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection.Metadata;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using UtilZ.Dotnet.AudioPlayer.Core;
using UtilZ.Dotnet.AudioPlayer.Native;
using UtilZ.Dotnet.Ex.Audio;
using UtilZ.Dotnet.WindowsDesktopEx.Winform;

namespace WinFormApp
{
    public partial class FTestWaveControl : Form
    {
        public FTestWaveControl()
        {
            InitializeComponent();
        }

        private void FTestWaveControl_Load(object sender, EventArgs e)
        {
            BASSHelper.Init();
            string filePath = @"E:\Music\bay bay bay.mp3";
            PcmDataInfo pcmDataInfo = AudioDataHelper.GetPcmDataShort(filePath);

            int handle = BASSHelper.StreamCreateFile(filePath);
            BASS_CHANNELINFO_INTERNAL info = BASSHelper.ChannelGetInfo(handle);
            //var waveInfo = new WaveInfo(WaveEncoding.Pcm, info.freq, (short)info.chans, (short)info.origres);
            var waveInfo = new WaveInfo(WaveEncoding.Pcm, info.freq, (short)info.chans, 16);

            //long lenth = BASSHelper.ChannelGetLength(handle, BASSMode.BASS_POS_BYTE);
            ////BASSHelper.ChannelGetData();



            //BASSHelper.ChannelGetData();

            //short[] pcmData

            double durationMillisecond = waveInfo.CalateDurationSeconds(pcmDataInfo.Data2.Length) * 1000;
            WavePlotPara plotPara = new WavePlotPara(DateTime.Now, durationMillisecond);
            waveControl1.UpdateData(plotPara, pcmDataInfo.Data2);
        }
    }
}
